<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>资金到位</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/buttons.css" />
<link rel="stylesheet" type="text/css" href="/jxcsxm/js/autocomplete/jquery.autocomplete.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-form.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/datagrid-detailview.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/util/jquery.cookie.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/YMLib.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/YWLib.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/autocomplete/jquery.autocomplete.js" ></script>
<style type="text/css">.table{border: 1px solid #FFE7BA;} .table tr{border: 1px solid #FFE7BA;} .table tr td{border: 1px solid #FFE7BA;}</style>
<script type="text/javascript">
var xmye=0;
var zhjhjebgq=0;
var zhysqje=0;
function yzsz(id){
	if(isNaN(Number($(id).val()))){  
		//当输入不是数字的时候，Number后返回的值是NaN;然后用isNaN判断。
        alert('请填入数字！');
        $(id).val('');
		$(id).focus();
    }
	// sumye($("#id").val());
}



$(function(){

	// $("#id").val(parent.YMLib.Var.data.id);
	$("#id").val(newGuid());
	$("#jhid").val(parent.YMLib.Var.data.jhid);
	$("#zhid").val(parent.YMLib.Var.data.zhid);
	$("#xmlx").val(parent.YMLib.Var.data.xmlx);
	$("#dscz").val(parent.YMLib.Var.data.dscz);
	$("#qxcz").val(parent.YMLib.Var.data.qxcz);
	$("#qtzj").val(parent.YMLib.Var.data.qtzj);
	$("#sqrq").val(parent.YMLib.Var.data.sqrq);
	$("#sqrq1").datebox('setValue',$("#sqrq").val());

	// $("#xmmc").val(parent.YMLib.Var.data.xmmc);
	// $("#twh").val(parent.YMLib.Var.data.twh);
	// $("#jwh").val(parent.YMLib.Var.data.jwh);
	// $("#jhje").val(parent.YMLib.Var.data.jhje);
	// $("#twh1").val(parent.YMLib.Var.data.twh.substring(0,parent.YMLib.Var.data.twh.indexOf("[")));
	// $("#twh2").val(parent.YMLib.Var.data.twh.substring(parent.YMLib.Var.data.twh.indexOf("[")+1,parent.YMLib.Var.data.twh.indexOf("]")));
	// $("#twh3").val(parent.YMLib.Var.data.twh.substring(parent.YMLib.Var.data.twh.indexOf("]")+1,parent.YMLib.Var.data.twh.indexOf("号")));
	// $("#jwh1").val(parent.YMLib.Var.data.jwh.substring(0,parent.YMLib.Var.data.jwh.indexOf("[")));
	// $("#jwh2").val(parent.YMLib.Var.data.jwh.substring(parent.YMLib.Var.data.jwh.indexOf("[")+1,parent.YMLib.Var.data.jwh.indexOf("]")));
	// $("#jwh3").val(parent.YMLib.Var.data.jwh.substring(parent.YMLib.Var.data.jwh.indexOf("]")+1,parent.YMLib.Var.data.jwh.indexOf("号")));
	//$("#sqrq1").datebox('setValue',parent.YMLib.Var.data.tbsj.substring(0,10));
	// var yf=new Date().getMonth()+1;
	// var day=new Date().getDate();
	// if(yf<10) yf='0'+yf;
	// if(day<10) day='0'+day;
	// $("#sqrq1").datebox('setValue',new Date().getFullYear()+"-"+yf+"-"+day);
	// $("#sqrq").val(parent.YMLib.Var.data.tbsj);
	// $("#xmdj").val(parent.YMLib.Var.data.xmdj);
	// $("#bz").val(parent.YMLib.Var.data.bz);
	//alert(parent.YMLib.Var.data.xmlx);
	

	zjdwxz();
	// sumye($("#id").val());
	// queryysqlist($("#id").val());
	
})
function zjdwtj(){
	if($("#id").val()==null||$("#id").val()=='')
	$("#id").val(newGuid());


	if($("#dscz").val()==''||$("#dscz").val()==null){
		alert("地市财政不能为空");
		return;
	}
	if($("#qxcz").val()==''||$("#qxcz").val()==null){
		alert("区县财政不能为空");
		return;
	}
	if($("#qtzj").val()==''||$("#qtzj").val()==null){
		alert("其它资金不能为空");
		return;
	}
	if($('#sqrq1').datebox("getValue")==''||$('#sqrq1').datebox("getValue")==null){
		alert("申请日期不能为空");
		return;
	}
	$('#sqrq').val($('#sqrq1').datebox("getValue"));

	loadjzt();
		$('#submit').ajaxSubmit({
			dataType:'json',
			success:function(msg){
				if(msg){
					disLoadjzt();
					alert("保存成功！");
					// zjdwxz();
					// sumye($("#id").val());
					// queryysqlist($("#id").val());
					parent.getTbXmList();
					// parent.$("#ysqlb").datagrid('reload');
					// closeWindow();
				}else{
					disLoadjzt();
					alert("保存失败！");
				}
			},
			error:function(msg){
				disLoadjzt();
				alert("保存失败！");
			}
		});
	
	
}
function zjdwxz(){
	$("#hm").val("");
	$("#bcje").val("");
	$("#zhjhje").val("");
	$("#syzhjhje").html("");
	$("#zhjhjetotal").val("");
	//alert("请重新选择用户！");
}
function sumye(id){
	$.ajax({
		url:'/jxcsxm/tjbb/sumye.do',
		data:"xmjbxx.id="+id,
		type:'post',
		dataType:'json',
		success:function(msg){
			
			var nums = (accSub($("#jhje").val(),msg.name));
			xmye=nums;
			$("#jhjetotal").val(nums);
			$("#syxmjhje").html("剩余资金:["+nums+"]万元");
		}
			
	})
}

function delsqmx(id){
	if(confirm("您确认删除吗？"))
	$.ajax({
		url:'/jxcsxm/tjbb/delsqmx.do',
		data:"xmjbxx.id="+id,
		type:'post',
		dataType:'json',
		success:function(msg){
			alert("删除成功");
			sumye($("#id").val());
			$("#ysqlb").datagrid('reload');
		}
			
	})
	
	
}


function queryysqlist(id){
	var params={'xmjbxx.jhid':id};
	var col;
	col=[[
	{field:'cz',title:'操作',align:'center',
		formatter: function(value,row,index){
			var result='<a style="color:#3399CC;text-decoration:none;" href="javascript:delsqmx('+"'"+row.id+"'"+')" >删除</a>';
			result+='<a style="text-decoration:none;color:#3399CC;" href=javascript:editsqXm("'+index+'")>编辑</a>&nbsp;&nbsp;';
			return result; 
		}
	},
	{field:'sqrq',title:'申请日期',width:100,align:'center'},
	{field:'zhjhje',title:'用户计划金额(万元)',width:100,align:'center'},
	{field:'bcje',title:'申请金额(万元)',width:100,align:'center'},
	{field:'hm',title:'户名',width:150,align:'center'},
	{field:'khh',title:'开户行',width:200,align:'center'},
	{field:'zh',title:'账号',width:200,align:'center'},
	{field:'xmlx',title:'项目类型',width:100,align:'center'},
	{field:'bz',title:'备注',width:200,align:'center'}
	
]];
	$('#ysqlb').datagrid({    
	    url:'/jxcsxm/tjbb/queryysqlist.do',
	    striped:true,
	    pagination:true,
	    rownumbers:true,
	    pageNumber:1,
	    pageSize:10,
	    checkOnSelect:true,
	    
	    queryParams: params,
	    columns:col
	}); 
}
function editsqXm(index){
	YMLib.Var.data=$('#ysqlb').datagrid('getRows')[index];
	YMLib.UI.createWindow('mywin',"编辑","sbzjqklrsqXm_bj.jsp",'mywin','600','300');	
}
</script>
</head>
<body>

<%--<form id="submit" action="/jxcsxm/tjbb/insertSbzjsq.do" method="post">--%>
<form id="submit" action="/jxcsxm/tjbb/insertDfzczjlr.do" method="post">
<table class='table' style="width: 100%; background-color: #FFE7BA; font-size: 12px"
			border="0" cellpadding="3" cellspacing="1">
	<input type="hidden" name="xmjbxx.id" id="id"  />
	<input type="hidden" name="xmjbxx.jhid" id="jhid"   /></td>
	<input type="hidden" name="xmjbxx.zhid" id="zhid"   /></td>
	<input type="hidden" name="xmjbxx.xmlx" id="xmlx"   /></td>


			<tr style="height: 35px;">
				<td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
					地市财政：</td>
				<td style="background-color: #ffffff; height: 20px;" align="left">
					<input type="text" name="xmjbxx.dscz" id="dscz" onchange="yzsz(this)" style="width: 120px" />万元
				</td>

			</tr>
			<tr style="height: 35px;">
				<td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
					区县财政：</td>
				<td style="background-color: #ffffff; height: 20px;" align="left">
					<input type="text" name="xmjbxx.qxcz" id="qxcz" onchange="yzsz(this)" style="width: 120px" />万元
				</td>

			</tr>
			<tr style="height: 35px;">
				<td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
					其它资金：</td>
				<td style="background-color: #ffffff; height: 20px;" align="left">
					<input type="text" name="xmjbxx.qtzj" id="qtzj" onchange="yzsz(this)" style="width: 120px" />万元
				</td>

			</tr>

			<tr style="height: 35px;">
				<td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
					申请日期：</td>
				<td style="background-color: #ffffff; height: 20px;" align="left">
					<input type="text" class='easyui-datebox' name="sqrq1" id="sqrq1" style="width: 124px" />
					<input type="hidden" name="xmjbxx.sqrq" id="sqrq" style="width: 124px" /></td>
			</tr>

			<tr style="height: 35px;">
				<td colspan="4" style="background-color: #ffffff;"align="center">
<%--				<a id='mybuttion3' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:zjdwxz()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion3')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion3')"  class="button button-tiny button-rounded button-raised button-primary">新增</a>--%>
				<a id='mybuttion1' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:zjdwtj()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion1')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion1')"  class="button button-tiny button-rounded button-raised button-primary">保存</a>
				<a id='mybuttion2' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:closeWindow()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion2')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion2')"  class="button button-tiny button-rounded button-raised button-primary">取消</a>
			
			</tr>
<%--			<tr style="height: 35px;" >--%>
<%--				<td colspan="4" style="background-color: #ffffff;"align="center">--%>
<%--				<table  id='ysqlb'>--%>
<%--				</table>--%>
<%--				</td>--%>
<%--			</tr>--%>
		</table>
	</form>
</body>
</html>